#ifndef _TIMER_H_
#define _TIMER_H_


#ifdef LINUX
//linux

#define __stdcall

#include <stdint.h>
#include <time.h>
#include <sys/time.h>

typedef int64_t kint64;
typedef unsigned int64_t kuint64;

#endif


#ifdef WIN32
//win32

#include <windows.h>

typedef __int64 kint64;
typedef unsigned __int64 kuint64;

#endif

#ifdef _XBOX
#include <xtl.h>
#endif


namespace Kernel
{
	class Timer
	{
	public:

		Timer();
		~Timer();

		void Enable(bool enable)
		{
			m_Enable = enable;

			m_Clock = GetTime();
		}

		bool IsEnable() const
		{
			return m_Enable;
		}

		void SetInterval(kint64 interval)
		{
			m_Interval = interval;
		}

		kint64 GetInterval() const
		{
			return m_Interval;
		}

		bool IsExpired();

		void Update();

		virtual void OnTick();

		kint64 GetTime();

	protected:
	private:

#if defined(WIN32) || defined(_XBOX)
		LARGE_INTEGER m_Freq;
#endif

		bool m_Enable;

		kint64 m_Interval;
		kint64 m_Clock;
	};

};



#endif

